package jcommon.chap1_j2seplus.object;

import java.math.BigDecimal;
import java.util.Date;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;

public class PoliticalCandidate {

	private String lastName;

	private String firstName;

	private Date dateOfBirth;

	private BigDecimal moneyRaised;

	private State homeState;

	public PoliticalCandidate(String lastName, String firstName,
			Date dateOfBirth, BigDecimal moneyRaised, State homeState) {
		super();
		this.lastName = lastName;
		this.firstName = firstName;
		this.dateOfBirth = dateOfBirth;
		this.moneyRaised = moneyRaised;
		this.homeState = homeState;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public Date getDateOfBirth() {
		return dateOfBirth;
	}

	public void setDateOfBirth(Date dateOfBirth) {
		this.dateOfBirth = dateOfBirth;
	}

	public BigDecimal getMoneyRaised() {
		return moneyRaised;
	}

	public void setMoneyRaised(BigDecimal moneyRaised) {
		this.moneyRaised = moneyRaised;
	}

	public State getHomeState() {
		return homeState;
	}

	public void setHomeState(State homeState) {
		this.homeState = homeState;
	}

	@Override
	public String toString() {
		return ReflectionToStringBuilder.toString(this);
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder(17, 37).append(firstName).append(lastName)
				.toHashCode();
	}

	@Override
	public boolean equals(Object obj) {
		boolean equals = false;
		if (obj != null
				&& PoliticalCandidate.class.isAssignableFrom(obj.getClass())) {
			PoliticalCandidate pcToCompare = (PoliticalCandidate) obj;
			equals = new EqualsBuilder().append(firstName,
					pcToCompare.firstName).append(lastName,
					pcToCompare.lastName).isEquals();
		}
		return equals;
	}

}
